package dao

import (
	"demo/global"
	"demo/internal/model"
)

func GetUser(tel string) model.Users {
	var result model.Users
	if err := global.DB.Where("tel=?", tel).Find(&result).Error; err != nil {
		return model.Users{}
	}
	return result
}

func ListUser() []model.Video {
	var result []model.Video
	if err := global.DB.Find(&result).Error; err != nil {
		return []model.Video{}
	}
	return result
}
func ListDemo() []model.Demo {
	var result []model.Demo
	if err := global.DB.Find(&result).Error; err != nil {
		return []model.Demo{}
	}
	return result
}
func Create[T any](data *T) bool {
	if err := global.DB.Create(data).Error; err != nil {
		return false
	}
	return true
}
func Delete[T any](data *T) bool {
	if err := global.DB.Delete(data).Error; err != nil {
		return false
	}
	return true
}
func Update[T any](data *T) bool {
	if err := global.DB.Updates(data).Error; err != nil {
		return false
	}
	return true
}
